package development.hdk.mindmapfornandroid;

import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
import android.view.Display;
import android.widget.RelativeLayout;
import development.hdk.node.Node;

public class CommonResources
{
  private static final float maxZoom = 5.0F;
  private static final float minZoom = 0.2F;
  private static final float zoomChange = 1.0F;
  public final int backgroundColor = Color.parseColor("#F2F2F2");
  private int displayHeight;
  private int displayWidth;
  private ProcessorActivity main;
  private float startZoom = 1.0F;
  public int surfaceColor;
  private float topLeftX = 0.0F;
  private float topLeftY = 0.0F;
  private float zoom = 1.0F;

  public CommonResources(Display paramDisplay, ProcessorActivity paramProcessorActivity)
  {
	  this.displayWidth = paramDisplay.getWidth();
	  this.displayHeight = paramDisplay.getHeight();
      this.main = paramProcessorActivity;
      this.topLeftX = 0.0F;
      this.topLeftY = 0.0F;
      this.startZoom = 1.0F;
  }

  public void decreaseZoom()//Co fix 
  {
	  if (this.zoom <= 1.0F)
	      modifyZoom((this.zoom - 0.2F) / this.zoom, this.displayWidth / 2, this.displayHeight / 2);
	    while (true)
	    {
	      modifyZoom((this.zoom - 1.0F) / this.zoom, this.displayWidth / 2, this.displayHeight / 2);
	      return;
	      
	    }
  }

  public float floatCoordinateX(int paramInt)
  {
    return paramInt / this.zoom + this.topLeftX;
  }

  public float floatCoordinateY(int paramInt)
  {
    return paramInt / this.zoom + this.topLeftY;
  }

  public float floatLength(int paramInt)
  {
    return paramInt / this.zoom;
  }

  public int getDisplayHeight()
  {
    return this.displayHeight;
  }

  public int getDisplayWidth()
  {
    return this.displayWidth;
  }

 public int getDrawableID(String paramString)
 {
    return this.main.getResources().getIdentifier(paramString, "drawable", this.main.getPackageName());
 }

  public float getTopLeftX()
  {
    return this.topLeftX;
  }

  public float getTopLeftY()
  {
    return this.topLeftY;
  }

  public float getZoom()
  {
    return this.zoom;
  }

  public float getstartZoom()
  {
    return this.startZoom;
  }

  public void goToStartPosition() //con fix
  {
	  //Node localNode = this.main.getRoot();
	    this.zoom = this.startZoom;
	    //Rect localRect = localNode.getNodeBounds();
	    int[] arrayOfInt = new int[2];
	    //this.main.relativeLayout.getLocationInWindow(arrayOfInt);
	    //this.topLeftX = (localNode.getLocationX() - this.displayWidth / 2.0F + arrayOfInt[0] + localRect.right / 2.0F);
	    //this.topLeftY = (localNode.getLocationY() - this.displayHeight / 2.0F + arrayOfInt[1] + localRect.bottom / 2.0F);
  }

  public void increaseZoom()//co fix
  {
    if (this.zoom >= 1.0F)
      modifyZoom((1.0F + this.zoom) / this.zoom, this.displayWidth / 2, this.displayHeight / 2);
    while (true)
    {
      modifyZoom((0.2F + this.zoom) / this.zoom, this.displayWidth / 2, this.displayHeight / 2);
      return;
      
    }
  }

  /*public boolean isAtStartPosition()//con fix
  {
    int i = 1;
   // Node localNode = this.main.getRoot();
    //Rect localRect = localNode.getNodeBounds();
    int[] arrayOfInt = new int[2];
    //this.main.relativeLayout.getLocationInWindow(arrayOfInt);
   // if ((this.topLeftX == localNode.getLocationX() - this.displayWidth / 2.0F + arrayOfInt[0] + localRect.right / 2.0F) && (this.topLeftY == localNode.getLocationY() - this.displayHeight / 2.0F + arrayOfInt[i] + localRect.bottom / 2.0F) && (this.zoom == this.startZoom));
    while (true)
    {
      return i;
      //i = false;
    }
  }*/

  public void modifyZoom(float paramFloat, int paramInt1, int paramInt2)
  {
    float f = paramFloat;
    if (f * this.zoom < 0.2F)
      f = 0.2F / this.zoom;
    while (true)
    {
      this.topLeftX -= (1.0F - f) * floatLength(paramInt1);
      this.topLeftY -= (1.0F - f) * floatLength(paramInt2);
      this.zoom = (f * this.zoom);
      if (f * this.zoom <= 5.0F)
        continue;
      f = 5.0F / this.zoom;
      return;
    }
  }

  public int pixelCoordinateX(float paramFloat)
  {
    return Math.round((paramFloat - this.topLeftX) * this.zoom);
  }

  public int pixelCoordinateY(float paramFloat)
  {
    return Math.round((paramFloat - this.topLeftY) * this.zoom);
  }

  public int pixelLength(float paramFloat)
  {
    return Math.round(paramFloat * this.zoom);
  }

  public void setTopLeftX(float paramFloat)
  {
    this.topLeftX = paramFloat;
  }

  public void setTopLeftY(float paramFloat)
  {
    this.topLeftY = paramFloat;
  }

  public void setZoom(float paramFloat)
  {
    this.zoom = paramFloat;
  }

  public void updateTopLeft(float paramFloat1, float paramFloat2)
  {
    this.topLeftX += floatLength((int)paramFloat1);
    this.topLeftY += floatLength((int)paramFloat2);
  }
}

/* Location:           D:\APKtoJava_RC2\tools\classes-dex2jar.jar
 * Qualified Name:     com.qdvsoftworks.schematicmind.CommonResources
 * JD-Core Version:    0.6.0
 */